package com.zzl.study.demo.config;

import com.zzl.study.demo.tool.BaiduMapService;
import com.zzl.study.demo.tool.BaiduTranslationService;
import com.zzl.study.demo.tool.MavenService;
import com.zzl.study.demo.tool.OpenMeteoService;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 基于stdio模式的MCP服务端配置类
 *
 * @author: zhangzl
 * @date: 2025/10/9 15:50
 * @version: 1.0
 */
@Configuration
public class StdioMcpServerConfig {

    /**
     * 向Spring容器中注入一个天气服务对象
     *
     * @return 天气服务对象
     */
    @Bean
    public OpenMeteoService openMeteoService() {
        return new OpenMeteoService();
    }

    /**
     * 向Spring容器中注入一个百度地图服务对象
     *
     * @return 百度地图服务对象
     */
    @Bean
    public BaiduMapService baiduMapService() {
        return new BaiduMapService();
    }

    /**
     * 向Spring容器中注入一个Maven服务对象
     *
     * @return Maven服务对象
     */
    @Bean
    public MavenService mavenService() {
        return new MavenService();
    }

    /**
     * 向Spring容器中注入一个百度翻译服务对象
     *
     * @return 百度翻译服务对象
     */
    @Bean
    public BaiduTranslationService baiduTranslationService() {
        return new BaiduTranslationService();
    }

    /**
     * 向Spring容器中注入一个MCP工具服务提供者
     *
     * @param openMeteoService        MCP天气工具服务端对象
     * @param baiduMapService         MCP地图工具服务端对象
     * @param mavenService            MCP maven工具服务端对象
     * @param baiduTranslationService 百度翻译工具服务端对象
     * @return MCP工具服务提供者
     */
    @Bean
    public ToolCallbackProvider weatherTools(OpenMeteoService openMeteoService, BaiduMapService baiduMapService, MavenService mavenService, BaiduTranslationService baiduTranslationService) {
        return MethodToolCallbackProvider.builder().toolObjects(openMeteoService, baiduMapService, mavenService, baiduTranslationService).build();
    }

}
